<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="com.stone.para.IConstant"%>
<%
	String contextPath = request.getContextPath();
	String m = request.getParameter("m");
//System.out.println("m=="+m);
String qxbtn = request.getParameter("qxbtn");
//System.out.println("qxbtn=="+qxbtn);
String countPerPage = request.getParameter("countPerPage");
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title><%=IConstant.PROGRAEM_TITLE%></title>
        <link rel="stylesheet" href="<%=contextPath%>/ext3/resources/css/ext-all.css" type="text/css"   />
        <link rel="stylesheet" href="<%=contextPath%>/css/main.css" type="text/css"  />
        <script src="<%=contextPath%>/ext3/adapter/ext/ext-base.js"></script>
        <script src="<%=contextPath%>/ext3/ext-all.js"></script>
        <script language="javascript">
            Ext.BLANK_IMAGE_URL = '<%=contextPath%>/ext3/resources/images/default/s.gif';
            Ext.QuickTips.init();
            Ext.form.Field.prototype.msgTarget = 'qtip';
            
			var currentWeeknum = '${currentWeeknum}';
			var currentNy = '${currentNy}';
			var monthid = '${monthid}'; 

			Ext.onReady(function(){
			
		    	Ext.lib.Ajax.defaultPostHeader += '; charset=utf-8';

		    	var myloader = new Ext.tree.TreeLoader({
                    		url : 'weekplanList!getWeek.do?month='
                });
		    
  				/* 生成Ttee,放到tree Div里面 */
           		var tree = new Ext.tree.TreePanel({
                        id:"mytree",   
                        root : new Ext.tree.AsyncTreeNode({   
                    		id : "-1", 
                    		draggable:false,
                    		text : "周计划"
	 					}),   
 						loader:myloader,
                        //rootVisible:false,
				        useArrows:true,
				        autoScroll:true,
				        animate:true,
				        containerScroll:true,
				        height : 520,
				        listeners:{"click":function(node){ 
				        
  								if (node.isLeaf() != undefined && node.isLeaf()){
				          			 //self.parent.frames["mainFrom"].src = "planMonth!initDetail.do?id=" + node.id;
				                    
				                } else {
				                	if (!node.isExpanded()) {
				                		node.expand();		
				                	} else {
				                		node.collapse();
				                	}              
				                }
				               // window.alert(node.text.length);
				                if (node.text.length == 1) {
								self.parent.frames["mainFrom"].location.href = "jsp/business/weekplan/treelistTabBase.jsp?url=weekplanList!getList.do&searchBean.con20=10&searchBean.con6=1&countPerPage=<%=countPerPage%>&qxbtn=<%=qxbtn%>&searchBean.con11=" + node.parentNode.text+ "-" +node.text;
				               //self.parent.frames["mainFrom"].location.href = "jsp/business/plan/treelistTabBase.jsp?url=planList!getList.do&searchBean.con20=10&searchBean.con6=1&countPerPage=28&qxbtn=<%=qxbtn%>&m=<%=m%>&ym=" + currentmonth.split("-")[0]+ "-" +node.text;
				                   	//self.parent.frames["mainFrom"].location.href = "planList!getList.do?ym=" + currentmonth.split("-")[0]+ "-" +node.text;
				                	//self.parent.frames["mainFrom"].location.href = "planMonth!initDetail.do?id=" + node.id;
				        		}
								
								
                    	}}
                });
 	
 				/* 加载数据前操作 */
            	myloader.on("beforeload", function(loader, node) { 
       				if( node.id == "-1") {
       					loader.url ='weekplanList!getWeek.do?month=-1';
       					return;
       				}
       				//window.alert(node.text);
       				if (node.text.length == 1) {
       					loader.url ='weekplanList!getWeek.do?month=' + node.parentNode.text + "-" + node.text;//window.alert(node.parentNode.text + "-" + node.text);
       					//loader.url ='planList!getMonthDate.do?month=' + node.parentNode.text ;
       				} else {
						loader.url ='weekplanList!getWeek.do?month=' + node.text;
					}
       			});
                
                /* 加载数据后操作 */
            	myloader.on("load", function(loader, node) { 
           			if (node.childNodes.length > 0) {
           				for(var i =0;i<node.childNodes.length;i++) {
							if(node.childNodes[i].text == currentNy
								 //|| node.childNodes[i].text == currentmonth.split("-")[1]
								 ) {
								node.childNodes[i].expand();
							} else {
								//if (monthid == node.childNodes[i].id) {
								if (node.childNodes[i].text == currentWeeknum) {
									node.childNodes[i].select();
									self.parent.frames["mainFrom"].location.href = "jsp/business/weekplan/treelistTabBase.jsp?url=weekplanList!getList.do&countPerPage=<%=countPerPage%>&searchBean.con11=" + currentNy+"&searchBean.con12=" + currentWeeknum;
			                
									//self.parent.frames["mainFrom"].location.href = "planMonth!initDetail.do?id=" + node.childNodes[i].id;
									//self.parent.frames["mainFrom"].location.href = "planList!getList.do?ym=" + currentmonth;
								}
							}
						}
           			}else{
           				self.parent.frames["mainFrom"].location.href = "jsp/business/weekplan/treelistTabBase.jsp?url=weekplanList!getList.do&countPerPage=100&searchBean.con11=" + currentNy+"&searchBean.con12=" + currentWeeknum;
           			}

                });
                
                var v = new Ext.Viewport({   
                		layout: 'border',   
                		margins:'5 0 5 5', 
                		layout:'fit',  
                		items: [tree],
                		renderTo : document.body

                });
                
                tree.root.expand();	
			});
		</script>
	</head>
	<body>
	</body>
</html>
